package com.gx.mxbbx.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gx.mxbbx.dao.FamilysMapper;
import com.gx.mxbbx.po.Familys;
import com.gx.mxbbx.service.FamilysService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.sql.Timestamp;
import java.util.List;

@Service
@Transactional
public class FamilysServiceImpl implements FamilysService {
    @Autowired
    private FamilysMapper familysMapper;

    public PageInfo<Familys> getfamilysList(String countyId, String familyId, String familyName, Integer currentPage, Integer limit) {
        PageHelper.startPage(currentPage, limit);
        List<Familys> list = familysMapper.getfamilysList(countyId, familyId, familyName);
        PageInfo<Familys> pageInfo = new PageInfo<Familys>(list);
        return pageInfo;
    }

    public Familys getlook(Integer id) {
        Familys familys = familysMapper.getlook(id);

        return familys;
    }

    public void familyadd(Familys familys) {
        familys.setCreateTime(new Timestamp(System.currentTimeMillis()));
        familys.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        familysMapper.familyadd(familys);
    }

    public Familys familysopenEdit(Integer id) {
        Familys familys = familysMapper.familysopenEdit(id);
        return familys;
    }

    public void familysedit(Familys familys) {
        familys.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        familysMapper.familysedit(familys);
    }

    public void familydelete(Integer id) {
        familysMapper.familydelete(id);
    }
}
